server {
    listen 80;
    server_name parolus.local;
    server_tokens on;
    client_max_body_size 500M;
    return 301 https://parolus.local$request_uri;
}

server {
    listen 443 ssl;
    server_name parolus.local;
    server_tokens on;
    client_max_body_size 500M;
    proxy_ssl_server_name on;

    error_page 404 =200 /index.html;

    ssl_certificate /etc/nginx/certs/localhost.crt;
    ssl_certificate_key /etc/nginx/certs/localhost.key;

    location / {
        root /usr/share/nginx/html/;
        try_files $uri $uri/index.html =404;
    }

    location /api {
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;

        proxy_pass https://fastapi-backend:8000;
        proxy_ssl_server_name on;
        proxy_read_timeout 300;
        proxy_connect_timeout 300;
        proxy_send_timeout 300;
    }
}
